import { Req } from '../../shared/request/request'
import { prefix } from '../../shared/client/axios'

export interface ItemRefType {
  num: number;
  name: string;
  doctor: string;
  status: number;
  intervalTime: string;
  therapyAddress: string;
}

export interface ProcessRefType {
  pId: string;
  startTime: string;
  items: ItemRefType[];
}

export interface Ddetail {
    uId: string
    password: string
    name: string
    gender: string
    cardId: string
    birthday: string
    phone: string
    homeAddress: string
    dId: string
}

export async function reqAddProcess(req: Req, processData: ProcessRefType): Promise<any> {
  const data = await req('post', `${prefix}/doctor/addProcess`, { data: processData, noToken: false })
  return data
}

export async function reqModifyProcess(req: Req, processData: ProcessRefType): Promise<any> {
  const data = await req('post', `${prefix}/doctor/login`, { data: processData, noToken: false })
  return data
}

export async function reqGetPaitentByCard(req: Req, cardId: string): Promise<any> {
  const data = await req('post', `${prefix}/doctor/findPatient`, { data: { findType: 'cardId', findKey: cardId }, noToken: false })
  return data
}

export async function reqGetPaitentByName(req: Req, name: string): Promise<any> {
  const data = await req('post', `${prefix}/doctor/findPatient`, { data: { findType: 'name', findKey: name }, noToken: false })
  return data
}

export async function reqGetItemsOpenable(req: Req): Promise<any> {
  const data = await req('get', `${prefix}/doctor/getItemsOpenable`, { noToken: false })
  return data
}

export async function reqModifyItemStatus(req: Req,prId:string, num: string, status: string): Promise<any> {
  const data = await req('post', `${prefix}/doctor/findPaitent`, { data: { prId: prId, num: num, status: status }, noToken: false })
  return data
}

export async function reqGetBeginItems(req: Req): Promise<any> {
  const data = await req('get', `${prefix}/doctor/getBeginItems`, { noToken: false })
  return data
}

export async function reqGetInfo(req: Req): Promise<any> {
  const data  = await req('get', `${prefix}/doctor/getInfo`, { noToken: false })
  return data
}

export async function reqUpdateInfo(req: Req, doctor: Ddetail): Promise<any> {
  const data = await req('post', `${prefix}/doctor/modifyInfo`, { noToken: false, data: {
    ...doctor
  } })
  return data
}